package cn.edu.nwpu.warehousemanagement.interceptors;

import jakarta.annotation.Nonnull;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

/**
 * 图标拦截类
 *
 * @author Loadstar
 * @version 1.0
 */
@Component
public class FaviconInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request,
                             @Nonnull HttpServletResponse response,
                             @Nonnull Object handler) throws Exception {
        if (!"GET".equalsIgnoreCase(request.getMethod()) || !request.getRequestURI().equals("/favicon.ico")) {
            return true;
        }
        response.setStatus(HttpStatus.NO_CONTENT.value()); // 设置状态码为204 No Content
        return false;
    }
}
